/**
 * @License: (C) Copyright 2013-2022
 * @Contact: abcque@outlook.com
 * @IDE: IntelliJ IDEA
 * @Encoding: utf-8
 * @Project: st2214 2215
 * @Package: PACKAGE_NAME
 * @File: DeckOfCards.java
 * @Time: 2022/12/16 11:30
 * @Author: abcque
 * @Description: 从 扑克牌中随机选择 3张牌
 * @Modifier:
 * @ModifyDate:
 * @ModifyRemark:
 */
public class DeckOfCards {
    public static void main(String[] args) {
        // step1、创建一个一维数组，大小 52，保存到 decks 中
        int[] decks = new int[52];

        // step2、存储扑克
        for (int i = 0; i < decks.length; i++) {
            decks[i] = i;
        }

        // step3、混洗扑克牌
        for (int i = 0; i < decks.length; i++) {
            int index = (int) (Math.random() * decks.length);
            int temp = decks[i];
            decks[i] = decks[index];
            decks[index] = temp;
        }

        //
        String[] suites = {"黑桃","红桃","方片","梅花"};
        String[] ranks = {"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"};

        for (int i = 0; i < 3; i++) {
            String suite = suites[decks[i] / 13];
            String rank = ranks[decks[i] % 13];

            System.out.println(suite + " " + rank);
        }
    }
}
